<template>
	<view>
		<!-- 标题栏 -->
		<view class="top-box tn-cool-bg-color-15--reverse">
			<view class="text-lg text-bold">余额记录</view>
		</view>
		<view class="main-list" style="">
			<view class="main-check margin-bottom-sm" v-for="(item, index) in moneyList" :key="index">
				<view class="main-check-image" style="display: flex; width: 100%; height: auto">
					<view class=""
						style="display: flex; width: 60%;height: 100%; flex-direction: column; padding: 10rpx 20rpx; ">
						<view class="text-lg text-bold ">
							<text class="text-red text-xl">{{ item.data.message }}</text>
						</view>
						<view class="text-lg text-bold text-gray margin-top-sm">备注：{{ item.data.tips }}</view>
						<view class="text-sm text-bold text-blue margin-top-xs">
							<uni-dateformat :threshold="[0,0]" class="content-text-ps text-gray" :date="item.data.time">
							</uni-dateformat>
						</view>
					</view>
					<view class="bottom-button">
						<view v-if="item.data.type == 1" class="text-red text-bold text-xxl">{{ item.data.money }}
						</view>
						<view v-else class="text-blue text-bold text-xxl">{{ item.data.money }}
						</view>
					</view>
				</view>
			</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	//数据库引入
	const db = uniCloud.database();
	const dbCmd = db.command;
	//引入全局变量
	let app = getApp();
	//引入测试数据
	export default {
		data() {
			return {
				openid: '',
				moneyList: []
			};
		},
		onShow() {},
		onLoad(options) {
			let that = this;
			//请求审核通过信息
			that.openid = options.openid;
			that.getMoneyList();
		},
		methods: {
			//取出记录
			getMoneyList() {
				let that = this;
				db.collection('moneyorder')
					.where({
						'data.openid': that.openid
					})
					.orderBy('data.time', 'desc')
					.get({})
					.then(res => {
						that.moneyList = res.result.data;
					});
			}
		}
	};
</script>

<style lang="scss">
	page {
		background-color: #f5f5f5;
	}

	.top-box {
		width: 100%;
		height: 100rpx;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.main-list {
		display: flex;
		width: 100%;
		padding: 20rpx 20rpx;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		// background-color: #0070ff;
	}

	.main-check {
		width: 100%;
		padding: 10rpx 0;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;
		border-radius: 20rpx;
		background: #fff;
	}

	.main-check-image {
		align-items: center;
	}

	.bottom-button {
		width: 300rpx;
		height: 100%;
		padding: 10rpx 50rpx;
		display: flex;
		align-items: flex-end;
		justify-content: center;
		flex-direction: column;
		// background-color: #0070FF;
	}
</style>
